//计算时间戳与现在的时间差
export function compareTimestamp(timestamp){
	const currentTime = new Date().getTime()
	const timeOff = currentTime - timestamp
	
	if(timeOff < 60000){
		return "1分钟内"
	}else if(timeOff < 3600000){
		return Math.floor(timeOff/60000) + '分钟';
	}else if(timeOff < 86400000){
		return Math.floor(timeOff/3600000) + '小时'
	}else if(timeOff < 2592000000){
		return Math.floor(timeOff/86400000) + '天'
	}else if(timeOff < 7776000000){
		return Math.floor(timeOff/2592000000) + '月'
	}else {
		return null
	}
}

export function gotoHome(){
	uni.showModal({
		title:"提示",
		content:"页面有误将返回首页",
		showCancel:false,
		success: (res) => {
			if(res.confirm){
				uni.reLaunch({
					url:"/pages/index/index"
				})
			}
		}
	})
}